<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>ThinkPHP5.0</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__STATIC__/style/bootstrap.css" rel="stylesheet">
    <link href="__STATIC__/style/font-awesome.css" rel="stylesheet">
    <link href="__STATIC__/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__STATIC__/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__STATIC__/style/demo.css" rel="stylesheet">
    <link href="__STATIC__/style/typicons.css" rel="stylesheet">
    <link href="__STATIC__/style/animate.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/plus/layui/css/layui.css">
    <script src="__STATIC__/plus/ueditor/ueditor.config.js"></script>
    <script src="__STATIC__/plus/ueditor/ueditor.all.min.js"></script>
    <script src="__STATIC__/plus/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script src="__STATIC__/plus/layer/layer.js"></script>
    <script src="__STATIC__/plus/layui/layui.js"></script>
</head>

<body>
    <!-- 头部 -->
    {include file="common/head"}

    <!-- /头部 -->

    <div class="main-container container-fluid">
        <div class="page-container">
            <!-- Page Sidebar -->
            <div class="page-sidebar" id="sidebar">
                <!-- Page Sidebar Header-->
                <div class="sidebar-header-wrapper">
                    <input class="searchinput" type="text">
                    <i class="searchicon fa fa-search"></i>
                    <div class="searchhelper">Search Reports, Charts, Emails or Notifications</div>
                </div>
                <!-- /Page Sidebar Header -->
                <!-- Sidebar Menu -->
                {include file="common/left"}
                <!-- /Sidebar Menu -->
            </div>
            <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li class="active">

                            <i class="fa fa-home"></i>
                            <a href="{:url('cate/index')}">
                                栏目管理
                            </a>
                        </li>
                        <li>栏目添加</li>
                    </ul>
                </div>
                <!-- /Page Breadcrumb -->

                <!-- Page Body -->
                <div class="page-body">
                    <div class="col-lg-12 col-sm-12 col-xs-12">
                        <form class="form-horizontal" role="form" action="{:url('admin/cate/save')}" method="post" enctype="multipart/form-data">
                            <div class="widget-body">
                                <div class="widget-main ">
                                    <div class="tabbable">
                                        <ul class="nav nav-tabs tabs-flat" id="myTab11">
                                            <li class="active">
                                                <a data-toggle="tab" href="#home11" aria-expanded="true">基本设置</a>
                                            </li>
                                            <li class="">
                                                <a data-toggle="tab" href="#profile11" aria-expanded="false">扩展设置</a>
                                            </li>
                                            <li class="">
                                                <a data-toggle="tab" href="#profile12" aria-expanded="false">内容设置</a>
                                            </li>
                                        </ul>
                                        <div class="tab-content tabs-flat">
                                            <div id="home11" class="tab-pane active">
                                                <div class="form-group">
                                                    <label class="col-lg-2 control-label">所属模型</label>
                                                    <div class="col-lg-2">
                                                        <select class="form-control" name="model_id"
                                                            data-bv-field="country">
                                                            {volist name="model" id="vo"}
                                                            <option value="{$vo.id}">{$vo.model_name}</option>
                                                            {/volist}
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-lg-2 control-label">所属栏目</label>
                                                    <div class="col-lg-2">
                                                        <select class="form-control" name="pid" data-bv-field="country">
                                                                <option value="0">顶级栏目</option>
                                                            {volist name="cate" id="vo"}
                                                            <option {if condition="$vo['id'] eq $id"} selected="selected" {/if} value="{$vo.id}">{$vo.catename}</option>
                                                            {/volist}
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="form-group has-feedback">
                                                    <label class="col-lg-2 control-label">栏目名称</label>
                                                    <div class="col-lg-2">
                                                        <input type="text" class="form-control" name="catename"
                                                            data-bv-field="jobTitle" value=""><i class="form-control-feedback"
                                                            data-bv-field="jobTitle" style="display: none;"></i>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label for="username"
                                                        class="col-sm-2 control-label no-padding-right">栏目属性</label>
                                                    <div class="col-sm-6">
                                                        <div class="radio" style="float:left; padding-left:10px;">
                                                            <label>
                                                                <input checked="checked" name="type" value="1"
                                                                    class="colored-blue radioItem" type="radio">
                                                                <span class="text">列表页栏目(可以发布文章)</span>
                                                            </label>
                                                        </div>
                                                        <div class="radio" style="float:left; padding-left:10px;">
                                                            <label>
                                                                <input name="type" value="2" class="colored-blue radioItem"
                                                                    type="radio">
                                                                <span class="text">封面频道栏目</span>
                                                            </label>
                                                        </div>
                                                        <div class="radio" style="float:left; padding-left:10px;">
                                                            <label>
                                                                <input name="type" value="3" class="colored-blue radioItem"
                                                                    type="radio" lay-filter="lanmu">
                                                                <span class="text">外链栏目</span>
                                                            </label>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group has-feedback" style="display:none;" id="link">
                                                        <label class="col-lg-2 control-label">外链地址</label>
                                                        <div class="col-lg-2">
                                                            <input type="text" class="form-control" value="" name="link"
                                                                data-bv-field="jobTitle">
                                                        </div>
                                                        <p style="color:red;">如果是外链栏目请在此输入地址</p>
                                                    </div>
                                                <div class="form-group">
                                                    <label for="username"
                                                        class="col-sm-2 control-label no-padding-right">是否显示</label>
                                                    <div class="col-sm-6">
                                                        <div class="radio" style="float:left; padding-left:10px;">
                                                            <label>
                                                                <input checked="checked" name="isshow" value="1"
                                                                    class="colored-blue" type="radio">
                                                                <span class="text">显示</span>
                                                            </label>
                                                        </div>
                                                        <div class="radio" style="float:left; padding-left:10px;">
                                                            <label>
                                                                <input name="isshow" value="2" class="colored-blue"
                                                                    type="radio">
                                                                <span class="text">隐藏</span>
                                                            </label>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group has-feedback">
                                                    <label class="col-lg-2 control-label">排序</label>
                                                    <div class="col-lg-2">
                                                        <input type="text" class="form-control" value="50" name="sort"
                                                            data-bv-field="jobTitle"><i class="form-control-feedback"
                                                            data-bv-field="jobTitle" style="display: none;"></i>
                                                    </div>
                                                </div>
                                            </div>

                                            <div id="profile11" class="tab-pane">
                                                <div class="form-group has-feedback">
                                                    <label class="col-lg-2 control-label">SEO标题</label>
                                                    <div class="col-lg-6">
                                                        <input type="text" class="form-control" value="" name="title"
                                                            data-bv-field="jobTitle"><i class="form-control-feedback"
                                                            data-bv-field="jobTitle" style="display: none;"></i>
                                                    </div>
                                                </div>
                                                <div class="form-group">

                                                    <label for="username"
                                                        class="col-sm-2 control-label no-padding-right"></label>
                                                    <div class="col-sm-2">
                                                        <button type="button" class="layui-btn" id="layimg"
                                                            style="background:#2dc3e8;">
                                                            <i class="layui-icon">&#xe67c;</i>上传图片
                                                        </button>
                                                        <input type="hidden" value="" id="imgcate" name="pic">
                                                        <div id="thumb_list" style="height:80px;"></div>
                                                    </div>

                                                </div>
                                                <div class="form-group has-feedback">
                                                    <label class="col-lg-2 control-label">关键字</label>
                                                    <div class="col-lg-6">
                                                        <input type="text" class="form-control" value="" name="keywords"
                                                            data-bv-field="jobTitle"><i class="form-control-feedback"
                                                            data-bv-field="jobTitle" style="display: none;"></i>
                                                    </div>
                                                </div>
                                                <div class="form-group has-feedback">
                                                    <label class="col-lg-2 control-label">描述</label>
                                                    <div class="col-lg-6">
                                                        <textarea class="form-control" rows="10" name="desc"></textarea>
                                                    </div>
                                                </div>
                                                <div class="form-group has-feedback">
                                                    <label class="col-lg-2 control-label">摘要</label>
                                                    <div class="col-lg-6">
                                                        <textarea class="form-control" rows="5"
                                                            name="remarks"></textarea>
                                                    </div>
                                                </div>

                                            </div>
                                            <div id="profile12" class="tab-pane">
                                                <div class="form-group">
                                                    <label for="username"
                                                        class="col-sm-2 control-label no-padding-right"></label>
                                                    <div class="col-sm-6">
                                                        <textarea name="content" id="content"></textarea>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <button type="submit" class="btn btn-default">保存信息</button>
                                    </div>
                                </div>

                            </div>
                        </form>
                    </div>
                </div>

            </div>
            <!-- /Page Body -->
        </div>
        <!-- /Page Content -->
    </div>
    </div>

    <!--Basic Scripts-->
    <script src="__STATIC__/style/jquery_002.js"></script>
    <script src="__STATIC__/style/bootstrap.js"></script>
    <script src="__STATIC__/style/jquery.js"></script>
    <!--Beyond Scripts-->
    <script src="__STATIC__/style/beyond.js"></script>

    <script>
        var ue = UE.getEditor('content', { initialFrameWidth: 1000, initialFrameHeight: 400 });
        layui.use(['upload','form'], function () {
            var upload = layui.upload;
            var form = layui.form;
            // form.on('radio(lanmu)', function(data){
            //     var link=$("#link").show();
            // }); 
            //执行实例
            var uploadInst = upload.render({
                elem: '#layimg' //绑定元素
                 , accept: 'images' //允许上传的文件类型
                , field: "picfile"
                , size: 2048 //最大允许上传的文件大小
                , url: "{:url('admin/common/uploadimg')}" //上传接口
                , done: function (res) {
                   // console.log(res.path);return false;
                    setTimeout(function () {

                        if (res.code == 1) {
                            layer.msg(res.msg, { icon: 1 });
                            $('#imgcate').val(res.path);
                           
                            var str;
                            str = "<span>";
                            str = str + '<img src="/' + res.path + '" alt="" height="80">';
                            str = str + '<button type="button" style="margin-top:-60px;margin-left:-27px;" class="layui-btn layui-btn-danger layui-btn-mini delimg" onclick="delimg(this);" data="' + res.path + '">';
                            str = str + '<i class="layui-icon">&#xe640;</i>';
                            str = str + '</button>';
                            str = str + '</span>';
                            $('#thumb_list').html(str);
                        } else {
                            layer.msg(res.msg, { icon: 2 });
                        }
                        layer.closeAll('loading'); //关闭loading
                    }, 1000);
                }
                , error: function () {
                    //请求异常回调
                }
            });
        });
        function delimg(o){
            var url=$(o).attr('data');
            $.post("{:url('common/delImg')}",{'url':url},function(res){
                console.log(res)
                if(res.code==1||res.code==2){
                    $('input[name=pic]').val("");
                    //删除/移除缩略图
                   $(o).parent().remove();
                   layer.msg(res.msg,{icon:1});
                }
                if(rse.code==0){
                    layer.msg(res.msg,{icon:2});
                }
            });
        }
        $(function(){
            // 监听外链栏目
            $(".radioItem").change(
                
                function() {
                var id = $(this).val();
                if (id == 3) {
                    $("#link").show();
                }else {
                    $("#link").hide();
                }
	        });
        })
    </script>


</body>

</html>